Add proposed patch to make test failures easier to debug
authorSimon McVittie <smcv@debian.org>
Sun, 18 Apr 2021 11:20:43 +0000 (12:20 +0100)
committerSimon McVittie <smcv@debian.org>
Sun, 18 Apr 2021 11:20:43 +0000 (12:20 +0100)
debian/patches/libtest-On-failure-make-it-clearer-what-has-happened.patch [new file with mode: 0644]
debian/patches/series

diff --git a/debian/patches/libtest-On-failure-make-it-clearer-what-has-happened.patch b/debian/patches/libtest-On-failure-make-it-clearer-what-has-happened.patch
new file mode 100644 (file)
index 0000000..f7ca592
--- /dev/null
@@ -0,0 +1,33 @@
+From: Simon McVittie <smcv@collabora.com>
+Date: Sun, 18 Apr 2021 12:16:45 +0100
+Subject: libtest: On failure, make it clearer what has happened
+
+If we fail as a result of `set -x`, It's often not completely obvious
+which command failed or how. Use a trap on ERR to show the command that
+failed, and its exit status.
+
+Signed-off-by: Simon McVittie <smcv@collabora.com>
+Forwarded: https://github.com/ostreedev/ostree/pull/2350
+---
+ tests/libtest.sh | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/tests/libtest.sh b/tests/libtest.sh
+index eda3b92..2e9a99d 100755
+--- a/tests/libtest.sh
++++ b/tests/libtest.sh
+@@ -46,6 +46,14 @@ run_exit_cmds() {
+ }
+ trap run_exit_cmds EXIT
++report_err () {
++  local exit_status="$?"
++  { { local BASH_XTRACEFD=3; } 2> /dev/null
++  echo "Unexpected nonzero exit status $exit_status while running: $BASH_COMMAND" >&2
++  } 3> /dev/null
++}
++trap report_err ERR
++
+ save_core() {
+   if [ -e core ]; then
+     cp core "$test_srcdir/core"
index b73e566a722cdb595a2da78c1c1ef5f43703efb2..e0991715b1af2542bdea546b63742c04d2d7a3be 100644 (file)
@@ -1 +1,2 @@
+libtest-On-failure-make-it-clearer-what-has-happened.patch
 debian/Skip-test-pull-repeated-during-CI.patch